package tbs.framework.auth.interfaces.impls;

import tbs.framework.base.model.ResultModel;
import tbs.framework.exceptions.IErrorConsumer;
import tbs.framework.log.ILogger;
import tbs.framework.log.annotations.AutoLogger;

/**
 * 全局请求的异常处理
 *
 * @author abstergo
 */
public class GlobalExceptionReturnedHandler implements IErrorConsumer {

    @AutoLogger
    ILogger logger;

    @Override
    public void onError(Throwable e) {
        logger.error(e, e.getMessage());
    }

    @Override
    public Object onErrorReturn(Throwable e) {
        onError(e);
        return ResultModel.failure(e.getMessage(), e);
    }
}
